<?
include("session.php");
$role_name = $_SESSION['role_name'];
$id = "";
if(isset($_GET['id'])) {
	$id = $_GET['id'];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/utils/form.checker.js"></script>
<script type="text/javascript" src="../webkit/datepicker/WdatePicker.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/> 
<body  bgcolor="#f4f4f4" style="margin:0px;" scroll=no>

<form name=f> 
<hr size=1>
<table width=100% cellspacing=1 cellpadding=3 id="basic_info_table"> 
	<tr>
        <td align=right nowrap>客户名称</td><td><input type='text' id="client_name" class='input' check='not_empty' warning='客户名称不能为空！'></td>  
		<td align=right>商机来源</td><td><select id="client_source" class='input'><option value=1>电信渠道</option><option value=2>三方代理</option></select></td>
	</tr>
	<tr>
		<td align=right>租用服务</td><td><select id="service_type" class='input'><option value=1>远端座席</option><option value=2>呼叫直通车</option><option value=3>电信侧座席</option><option value=4>IVR</option><option value=5>BPO</option></select></td>
		<td align=right>签约数量</td><td><input type='text' id="order_count" class='input' check='integer' warning='签约个数必须为数字！'></td>
	</tr>
	<tr>
		<td align=right>签约单价</td><td><input type='text' id="order_price" class='input' check='integer' warning='签约单价必须为数字！'></td>
		<td align=right>签约时间</td><td><input type='text' id="order_date" class='datepicker' check='not_empty' warning='签约时间不能为空！' class="datepicker" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" value="<?echo date("Y-m-d")?>"></td>
	</tr>
	<tr>
		<td align=right>用户归属</td><td><select id="user_name" class='input'><option value=''>-请选择-</option></select></td>
		<td align=right nowrap>提成比例</td><td><input type='text' id="money_rate" class='input' check='numeric' warning='提成比例必须为数字！' value=0></td>
	</tr>
	<tr>
		<td align=right>结算周期</td><td><select id="pay_period" class='input'><option value='1'>按月</option><option value='2'>按季</option><option value='3'>按年</option></select></td>
		<td align=right>客户区域</td><td><input type='text' id="client_area" class='input' check='not_empty' warning='客户区域不能为空！'></td>
	</tr>
	<tr>
		<td align=right>客户状态</td><td><select id="client_status" class='input'><option value='1'>有效</option><option value='0'>无效</option></select></td>
		<!--
		<td align=right>定制开发</td><td><input type='text' id="deve_price" class='input' check='not_empty' warning='定制开发费不能为空！' value=0></td>
		-->
		<td align=right>客户行业</td>
		<td>
			<select id="client_type" class='input'><option value='党政军'>党政军</option><option value='卫生事业'>卫生事业</option><option value='家政服务'>家政服务</option><option value='房地产'>房地产</option><option value='汽车4S店'>汽车4S店</option><option value='美容健身'>美容健身</option><option value='快递物流'>快递物流</option><option value='旅游签证'>旅游签证</option><option value='教育行业'>教育行业</option><option value='制造企业'>制造企业</option><option value='销售代理'>销售代理</option><option value='文化传媒'>文化传媒</option><option value='食品企业'>食品企业</option><option value='商超零售'>商超零售</option><option value='IT行业'>IT行业</option><option value='金融保险'>金融保险</option></select>
		</td>
	</tr>
	<tr>
		<td align=right>备　　注</td><td colspan=3><textarea style="width:500px;" rows=5 id="service_desc"></textarea></td>
	</tr>
	<input type='hidden' id="id">
</form>	

<table width=100% cellspacing=1 cellpadding=3>
	<tr>
		<td align=center>
		<hr size=1>
		<input type="button" id="btn_save" class="button" value="保存信息" onclick="save()">　　<input type="button" class="button" value="关闭窗口" onclick="parent.closeDlg()"></td>
	</tr>
</table>

<script type="text/javascript">
	var op = "<?echo $_GET['op']?>";
	var f = document.f;
	function save() { 
		if(FormChecker.doCheck(f)) {
			var params = {};
			var els = f.elements;
			for(var i=0; i<els.length; i++) {
				if(els[i].type == "button") continue;
				params[els[i].id] = els[i].value;
			}

			$.post("client_query.php?action="+op, params, function(data) {
				if(data.indexOf("ok") == 0) {
					alert("数据保存成功!");
					parent.refreshGrid();
					parent.closeDlg();
                } else {  
					alert(data);
				}
			});
		}
	}; 

	

	function init() {
	<?
	if($_GET['op'] == 'edit') {
	?>
	$.get("client_query.php?action=get&id=<?echo $_GET['id']?>", function(data){
		eval("var row = "+data);
		for(var k in row) {
			$('#'+k).val(row[k]);
		}
	});
	<?
	}
	?>
	}

	$(function() {
		$.get("user_query.php?action=get_select_options", function(data) {
			var arr = data.split("$");
			for(var i=0; i<arr.length; i++){
				var kv = arr[i].split(',');
				f.user_name.options[i+1] = new Option(kv[1], kv[0]);
			}
		});
		init();
	});
</script>
</body>
</html>